Skip to content
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

[typescript-fetch] add samples of nullable enum #7754

Merged
merged 2 commits into from
Nov 13, 2020

Conversation

berlysia
Copy link
Contributor

resolves #7745

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.
  • If contributing template-only or documentation-only changes which will change sample output, build the project beforehand.
  • Run the shell script ./bin/generate-samples.shto update all Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*. For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

@TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @topce (2018/10) @akehir (2019/07) @petejohansonxo (2019/11) @amakhrov (2020/02)

@@ -1119,6 +1119,42 @@ paths:
responses:
200:
description: The instance started successfully
/fake/enum-request:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this file should be copied rather than modified to avoid changing other test data

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to make a separate file of minimal yaml?
I'm doing this because I saw this description:

For new test cases, please add to the Fake Petstore spec

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, ok, yeah so its fine as it is, thanks

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is still an issue with this test, could you fix it?
https://cloud.drone.io/OpenAPITools/openapi-generator/12016/1/5

@berlysia berlysia force-pushed the typescript-fetch-improvements branch from a633fb9 to d35283e Compare October 19, 2020 21:24
@berlysia

This comment has been minimized.

@berlysia berlysia force-pushed the typescript-fetch-improvements branch from d35283e to ce4990e Compare October 19, 2020 21:29
@macjohnny
Copy link
Member

@berlysia there are still some samples that need to be updated.

@berlysia
Copy link
Contributor Author

berlysia commented Oct 20, 2020

#7754 (comment) is fixed, but samples have difference.
It seems some difference between ./bin/generate-samples.sh result and reported on CI.
@macjohnny Which is prefer, or another?

on my env (42 changed, 329 files created)
> git status
On branch typescript-fetch-improvements
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   samples/client/petstore/csharp/OpenAPIClient/README.md
        modified:   samples/client/petstore/csharp/OpenAPIClient/docs/DefaultApi.md
        modified:   samples/client/petstore/csharp/OpenAPIClient/docs/NullableClass.md
        modified:   samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Api/DefaultApi.cs
        modified:   samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/NullableClass.cs
        modified:   samples/client/petstore/perl/README.md
        modified:   samples/client/petstore/perl/docs/DefaultApi.md
        modified:   samples/client/petstore/perl/docs/NullableClass.md
        modified:   samples/client/petstore/perl/lib/WWW/OpenAPIClient/DefaultApi.pm
        modified:   samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/NullableClass.pm
        modified:   samples/client/petstore/php/OpenAPIClient-php/README.md
        modified:   samples/client/petstore/php/OpenAPIClient-php/docs/Api/DefaultApi.md
        modified:   samples/client/petstore/php/OpenAPIClient-php/docs/Model/NullableClass.md
        modified:   samples/client/petstore/php/OpenAPIClient-php/lib/Api/DefaultApi.php
        modified:   samples/client/petstore/php/OpenAPIClient-php/lib/Model/NullableClass.php
        modified:   samples/client/petstore/ruby-faraday/README.md
        modified:   samples/client/petstore/ruby-faraday/docs/DefaultApi.md
        modified:   samples/client/petstore/ruby-faraday/docs/NullableClass.md
        modified:   samples/client/petstore/ruby-faraday/lib/petstore/api/default_api.rb
        modified:   samples/client/petstore/ruby-faraday/lib/petstore/models/nullable_class.rb
        modified:   samples/client/petstore/ruby/README.md
        modified:   samples/client/petstore/ruby/docs/DefaultApi.md
        modified:   samples/client/petstore/ruby/docs/NullableClass.md
        modified:   samples/client/petstore/ruby/lib/petstore/api/default_api.rb
        modified:   samples/client/petstore/ruby/lib/petstore/models/nullable_class.rb
        modified:   samples/client/petstore/scala-gatling/bin/gatling/org/openapitools/client/model/Order.scala
        modified:   samples/openapi3/client/petstore/python/README.md
        modified:   samples/openapi3/client/petstore/python/docs/DefaultApi.md
        modified:   samples/openapi3/client/petstore/python/docs/NullableClass.md
        modified:   samples/openapi3/client/petstore/python/petstore_api/api/default_api.py
        modified:   samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py
        modified:   samples/schema/petstore/mysql/Model/NullableClass.sql
        modified:   samples/schema/petstore/mysql/mysql_schema.sql
        modified:   samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/FakeApi.java
        modified:   samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/FakeApiService.java
        modified:   samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/NullableClass.java
        modified:   samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/impl/FakeApiServiceImpl.java
        modified:   samples/server/petstore/php-laravel/lib/app/Http/Controllers/DefaultController.php
        modified:   samples/server/petstore/php-laravel/lib/app/Models/NullableClass.php
        modified:   samples/server/petstore/php-laravel/lib/routes/api.php
        modified:   samples/server/petstore/php-lumen/lib/app/Http/Controllers/DefaultApi.php
        modified:   samples/server/petstore/php-lumen/lib/routes/web.php

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        samples/client/petstore/groovy/bin/
        samples/client/petstore/kotlin-gson/bin/
        samples/client/petstore/kotlin-jackson/bin/
        samples/client/petstore/kotlin-json-request-string/bin/
        samples/client/petstore/kotlin-jvm-okhttp4-coroutines/bin/
        samples/client/petstore/kotlin-moshi-codegen/bin/
        samples/client/petstore/kotlin-nonpublic/bin/
        samples/client/petstore/kotlin-nullable/bin/
        samples/client/petstore/kotlin-okhttp3/bin/
        samples/client/petstore/kotlin-retrofit2-rx3/bin/
        samples/client/petstore/kotlin-retrofit2/bin/
        samples/client/petstore/kotlin-string/bin/
        samples/client/petstore/kotlin-threetenbp/bin/
        samples/client/petstore/kotlin-uppercase-enum/bin/
        samples/client/petstore/kotlin/bin/main/
        samples/client/petstore/kotlin/bin/test/
        samples/client/petstore/scala-gatling/bin/gatling/org/openapitools/client/model/InlineObject.scala
        samples/client/petstore/scala-gatling/bin/gatling/org/openapitools/client/model/InlineObject1.scala

no changes added to commit (use "git add" and/or "git commit -a")
on CI
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   samples/client/petstore/csharp/OpenAPIClient/README.md
	modified:   samples/client/petstore/csharp/OpenAPIClient/docs/DefaultApi.md
	modified:   samples/client/petstore/csharp/OpenAPIClient/docs/NullableClass.md
	modified:   samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Api/DefaultApi.cs
	modified:   samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/NullableClass.cs
	modified:   samples/client/petstore/perl/README.md
	modified:   samples/client/petstore/perl/docs/DefaultApi.md
	modified:   samples/client/petstore/perl/docs/NullableClass.md
	modified:   samples/client/petstore/perl/lib/WWW/OpenAPIClient/DefaultApi.pm
	modified:   samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/NullableClass.pm
	modified:   samples/client/petstore/php/OpenAPIClient-php/README.md
	modified:   samples/client/petstore/php/OpenAPIClient-php/docs/Api/DefaultApi.md
	modified:   samples/client/petstore/php/OpenAPIClient-php/docs/Model/NullableClass.md
	modified:   samples/client/petstore/php/OpenAPIClient-php/lib/Api/DefaultApi.php
	modified:   samples/client/petstore/php/OpenAPIClient-php/lib/Model/NullableClass.php
	modified:   samples/client/petstore/ruby-faraday/README.md
	modified:   samples/client/petstore/ruby-faraday/docs/DefaultApi.md
	modified:   samples/client/petstore/ruby-faraday/docs/NullableClass.md
	modified:   samples/client/petstore/ruby-faraday/lib/petstore/api/default_api.rb
	modified:   samples/client/petstore/ruby-faraday/lib/petstore/models/nullable_class.rb
	modified:   samples/client/petstore/ruby/README.md
	modified:   samples/client/petstore/ruby/docs/DefaultApi.md
	modified:   samples/client/petstore/ruby/docs/NullableClass.md
	modified:   samples/client/petstore/ruby/lib/petstore/api/default_api.rb
	modified:   samples/client/petstore/ruby/lib/petstore/models/nullable_class.rb
	modified:   samples/openapi3/client/petstore/python/README.md
	modified:   samples/openapi3/client/petstore/python/docs/DefaultApi.md
	modified:   samples/openapi3/client/petstore/python/docs/NullableClass.md
	modified:   samples/openapi3/client/petstore/python/petstore_api/api/default_api.py
	modified:   samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py
	modified:   samples/schema/petstore/mysql/Model/NullableClass.sql
	modified:   samples/schema/petstore/mysql/mysql_schema.sql
	modified:   samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/FakeApi.java
	modified:   samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/FakeApiService.java
	modified:   samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/NullableClass.java
	modified:   samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/impl/FakeApiServiceImpl.java
	modified:   samples/server/petstore/php-laravel/lib/app/Http/Controllers/DefaultController.php
	modified:   samples/server/petstore/php-laravel/lib/app/Models/NullableClass.php
	modified:   samples/server/petstore/php-laravel/lib/routes/api.php
	modified:   samples/server/petstore/php-lumen/lib/app/Http/Controllers/DefaultApi.php
	modified:   samples/server/petstore/php-lumen/lib/routes/web.php

@macjohnny
Copy link
Member

@berlysia in order to make it easier to review this PR and avoid changing the samples of other generators, I would copy the https://github.com/OpenAPITools/openapi-generator/blob/ce4990ecc3ceba25a62d80e4880f91807a1b35b4/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml file instead of modifying it. @wing328 any objections?

@berlysia
Copy link
Contributor Author

I will add minimal yaml which contains nullable enum values. It's too much large spec to copy, I think.

@berlysia berlysia force-pushed the typescript-fetch-improvements branch from ce4990e to 1af3421 Compare October 24, 2020 07:45
Comment on lines 18 to 22
schema:
allOf:
- $ref: "#/components/schemas/StringEnum"
type: string
nullable: true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. OAI/OpenAPI-Specification#1368 (comment)

In JSON Schema, allOf doesn't work like inheritance. It means that the value must conform independently to each of the listed subschemas, and it must also conform to any other conditions specified directly in the schema.

I'll remove this because quoted as above and I've found OAI/OpenAPI-Specification#2244 . Generated codes are roughly usable but this yaml does not conform OpenAPI Spec, currently.

@berlysia berlysia changed the title [typescript-fetch] support enum with nullable: true [typescript-fetch] support inlined enum with nullable: true Oct 24, 2020
@berlysia berlysia force-pushed the typescript-fetch-improvements branch from 57804e9 to bdd2318 Compare October 26, 2020 01:58
@berlysia
Copy link
Contributor Author

berlysia commented Oct 26, 2020

@macjohnny Please take another look, this PR just adds samples now.
This is why I'm doing this. Please point it out something misunderstood.

I've finally noticed that "referenced nullable enum" is one of the hottest issue of OpenAPI Generator and OpenAPI Specification.

How we define a nullable variation of defined schema(includes enum)

for OAS v3.0 (it's weird along with spec, but useful codes will be generated):

propertyName:
  nullable: true
  allOf:
    - $ref: "#/pointer/to/defined/schema"

for OAS v3.1(not works currently because it's not implemented):

propertyName:
  oneOf:
    - type: "null"
    - $ref: "#/pointer/to/defined/schema"

see. OAI/OpenAPI-Specification#1368 (comment) and OAI/OpenAPI-Specification#1368 (comment)

@berlysia berlysia force-pushed the typescript-fetch-improvements branch from bdd2318 to 42e3364 Compare October 26, 2020 18:47
@berlysia berlysia changed the title [typescript-fetch] support inlined enum with nullable: true [typescript-fetch] add samples of nullable enum Oct 26, 2020
Copy link
Member

@macjohnny macjohnny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@macjohnny macjohnny added this to the 5.0.0 milestone Nov 13, 2020
@macjohnny macjohnny merged commit 920eafc into OpenAPITools:master Nov 13, 2020
@berlysia berlysia deleted the typescript-fetch-improvements branch September 28, 2021 10:31
@aaronabf aaronabf mentioned this pull request Dec 25, 2023
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] [typescript-fetch] nullable: true is not respected with enum
2 participants