Created by: jafin
- Conditionals for string and Object to still throw ArgumentException but NOT for non nullable primitives
- Escape type in XML comment to avoid issues with types rendering. Relates to #11426 11426
Part of schema causing challenges:
PolymorphicProperty:
oneOf:
- type: boolean
- type: string
- type: object
- type: array
items:
$ref: '#/components/schemas/StringArrayItem'
StringArrayItem:
type: string
format: string
-An oneOf
notnullable
with primitives as options would generate non functioning code in the csharp-netcore generator.
Issues encountered
Checking non nullable primitive for null.
existing (compile error)
public PolymorphicProperty(bool actualInstance)
{
//...
this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null.");
}
change: (only for primitives, Note: I noticed that Object
and string
are returning isPrimitive:true in the model, so extra checks where made for these types)
public PolymorphicProperty(bool actualInstance)
{
//...
this.ActualInstance = actualInstance;
}
XML Comments should be escaped to accomodate to Generic <> Types
existing
/// <summary>
/// Initializes a new instance of the <see cref="PolymorphicProperty" /> class
/// with the <see cref="List<string>" /> class
/// </summary>
/// <param name="actualInstance">An instance of List<string>.</param>
better
/// <summary>
/// Initializes a new instance of the <see cref="PolymorphicProperty" /> class
/// with the <see cref="List<string>" /> class
/// </summary>
/// <param name="actualInstance">An instance of List<string>.</param>
Getter for Generic Type has invalid method name
existing (won't compile)
public List<string> GetList<string>()
changes to:
public List<string> GetListString()
PR checklist
-
Read the contribution guidelines. -
Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community. -
Run the following to build the project and update samples: ./mvnw clean package ./bin/generate-samples.sh ./bin/utils/export_docs_generators.sh
TRIED TO RUN
/bin/generate-sample.sh
but it errors withsamples/openapi3/client/petstore/java/jersey2-java8-special-charactersCan't load config class with name 'java-micronaut-server'
EDIT : .Possibly misunderstood , was able to run and update generated code
/bin/generate-samples.sh ./bin/configs/csharp-netcore*
Please advise if there is anything more I should do for this PR, I am new to this repo and nill exposure to Java.
-
File the PR against the correct branch: master
(5.3.0),6.0.x
-
If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request. @mandrean @frankyjuang @shibayan @Blackclaws @lucamazzanti