-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
[php-nextgen] Add anyof Support #24306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ckoegel
wants to merge
23
commits into
OpenAPITools:master
Choose a base branch
from
ckoegel:php-nextgen-anyof
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,452
−170
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
43b94b1
update codegen
ckoegel f69799d
update test codegen
ckoegel 3843c5c
mustache templates
ckoegel 64d4a0f
generate samples
ckoegel 17bcfc7
update model doc template
ckoegel c788027
regenerate samples
ckoegel 24f6b9b
add tests
ckoegel 8161b24
regenerate samples
ckoegel 72feca0
fix comment per cubic review
ckoegel 3c6eb0f
update composed model tests
ckoegel da12fc3
use Throwable to preserve error catch
ckoegel 0a3d632
update model serializer per cubic review
ckoegel 9a21acf
regenerate samples
ckoegel b86c6fc
regenerate tests
ckoegel d95922f
fix object serialization per cubic review
ckoegel fe2f126
split composed into oneOf/anyOf
ckoegel c31c074
regenerate samples
ckoegel a3fad7b
Merge branch 'master' of https://github.com/ckoegel/openapi-generator…
ckoegel 457f0f4
samples again
ckoegel cbaf8c7
address cubic json decoding feedback
ckoegel b2a7e37
address cubic type validation feedback
ckoegel 1ac0a88
Update modules/openapi-generator/src/main/resources/php-nextgen/Objec…
ckoegel 9add223
generate samples
ckoegel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
122 changes: 65 additions & 57 deletions
122
...i-generator/src/main/java/org/openapitools/codegen/languages/PhpNextgenClientCodegen.java
Large diffs are not rendered by default.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
modules/openapi-generator/src/main/resources/php-nextgen/AnyOfInterface.mustache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| <?php | ||
| /** | ||
| * AnyOfInterface | ||
| * | ||
| * PHP version 8.1 | ||
| * | ||
| * @package {{modelPackage}} | ||
| * @author OpenAPI Generator team | ||
| * @link https://openapi-generator.tech | ||
| */ | ||
|
|
||
| {{>partial_header}} | ||
|
|
||
| /** | ||
| * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
| * https://openapi-generator.tech | ||
| * Do not edit the class manually. | ||
| */ | ||
|
|
||
| namespace {{modelPackage}}; | ||
|
|
||
| /** | ||
| * Interface implemented by models generated from an `anyOf` schema. | ||
| * | ||
| * An `anyOf` schema is not represented by a value object; instead a value is one of the | ||
| * member types. Classes implementing this interface only carry the metadata that | ||
| * {@see ObjectSerializer::deserialize()} needs to resolve the concrete member type. | ||
| * | ||
| * @package {{modelPackage}} | ||
| * @author OpenAPI Generator team | ||
| */ | ||
| interface AnyOfInterface | ||
| { | ||
| /** | ||
| * List of the types a value of this `anyOf` schema may be. Each entry uses the same | ||
| * notation as the values of {@see ModelInterface::openAPITypes()}. | ||
| * | ||
| * @return string[] | ||
| */ | ||
| public static function getAnyOfTypes(): array; | ||
|
|
||
| /** | ||
| * Name of the discriminator property used to resolve the concrete member type, or null | ||
| * when the schema has no discriminator. | ||
| * | ||
| * @return string|null | ||
| */ | ||
| public static function getAnyOfDiscriminator(): ?string; | ||
|
|
||
| /** | ||
| * Mapping of discriminator values to the concrete member type. Empty when the schema has | ||
| * no discriminator. | ||
| * | ||
| * @return array<string,string> | ||
| */ | ||
| public static function getAnyOfDiscriminatorMappings(): array; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
modules/openapi-generator/src/main/resources/php-nextgen/model_anyof.mustache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| class {{classname}} implements AnyOfInterface | ||
| { | ||
| /** | ||
| * The original name of the model. | ||
| * | ||
| * @var string | ||
| */ | ||
| public const MODEL_NAME = '{{name}}'; | ||
|
|
||
| /** | ||
| * The discriminator property name, or null when the schema has no discriminator. | ||
| * | ||
| * @var string|null | ||
| */ | ||
| public const DISCRIMINATOR = {{#discriminator}}'{{propertyBaseName}}'{{/discriminator}}{{^discriminator}}null{{/discriminator}}; | ||
|
|
||
| /** | ||
| * {@inheritdoc} | ||
| */ | ||
| public static function getAnyOfTypes(): array | ||
| { | ||
| return [ | ||
| {{#composedSchemas}}{{#anyOf}}'{{{dataType}}}'{{^-last}}, | ||
| {{/-last}}{{/anyOf}}{{/composedSchemas}} | ||
| ]; | ||
| } | ||
|
|
||
| /** | ||
| * {@inheritdoc} | ||
| */ | ||
| public static function getAnyOfDiscriminator(): ?string | ||
| { | ||
| return self::DISCRIMINATOR; | ||
| } | ||
|
|
||
| /** | ||
| * {@inheritdoc} | ||
| */ | ||
| public static function getAnyOfDiscriminatorMappings(): array | ||
| { | ||
| return [ | ||
| {{#discriminator}}{{#mappedModels}}'{{mappingName}}' => '\{{modelPackage}}\{{modelName}}'{{^-last}}, | ||
| {{/-last}}{{/mappedModels}}{{/discriminator}} | ||
| ]; | ||
| } | ||
| } |
19 changes: 19 additions & 0 deletions
19
modules/openapi-generator/src/main/resources/php-nextgen/model_doc.mustache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.