Skip to content

Support for Constant Value in API #1620

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

Closed
duckladydinh opened this issue Jun 29, 2018 · 4 comments
Closed

Support for Constant Value in API #1620

duckladydinh opened this issue Jun 29, 2018 · 4 comments

Comments

@duckladydinh
Copy link

Since OpenAPI can be used to generate client code, it is good to support some constant value in the API itself.

Use case: When you add type info to a class as a properties, we need that property for deserialization and the value of this property will never change.

@MikeRalphson
Copy link
Member

Can you not do this with an enum property which only has one value?

MySchema:
  type: object
  properties:
    MyProperty:
      type: string
      enum:
      - constantValue

@hkosova
Copy link
Contributor

hkosova commented Jun 29, 2018

Possibly related: #1313

@marcusbesjes
Copy link

Can you not do this with an enum property which only has one value?

Yes thats how it needs to be done now, but it's a bit verbose and it doesn't look nice in your documentation (generated web pages), where it will show as an expandable list of one item VS just the string value.

@MikeRalphson
Copy link
Member

Closing, as this is a dupe of #1313 as @hkosova observed.

LucasRoesler added a commit to contiamo/go-base that referenced this issue Jul 20, 2020
**What**
- Generate a Go `const` if the enum values has exactly one element
- See OAI/OpenAPI-Specification#1313 and
  OAI/OpenAPI-Specification#1620 as examples
  where the openapi team blessed the "singleton enum" example

Signed-off-by: Lucas Roesler <[email protected]>
rdner pushed a commit to contiamo/go-base that referenced this issue Jul 20, 2020
**What**
- Generate a Go `const` if the enum values has exactly one element
- See OAI/OpenAPI-Specification#1313 and
  OAI/OpenAPI-Specification#1620 as examples
  where the openapi team blessed the "singleton enum" example

Signed-off-by: Lucas Roesler <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants