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

[REQ] Add isDeprecated field to schema object. #3358

Open
yuji38kwmt opened this issue Jul 14, 2019 · 5 comments
Open

[REQ] Add isDeprecated field to schema object. #3358

yuji38kwmt opened this issue Jul 14, 2019 · 5 comments

Comments

@yuji38kwmt
Copy link
Contributor

Is your feature request related to a problem? Please describe.

I created the following yaml file that tag field of Pet Object is deprecated.
I executed generate command with -DdebugModels option and I printed JSON model.
But json model does not include isDeprecated field.
So I can not use isDrecated variable in model.mustache file.

petstore.yaml

openapi: "3.0.0"
info:
  version: 1.0.0
  title: Swagger Petstore
  license:
    name: MIT
servers:
  - url: http://petstore.swagger.io/v1
paths:
  /pets/{petId}:
    get:
      summary: Info for a specific pet
      operationId: showPetById
      tags:
        - pets
      parameters:
        - name: petId
          in: path
          required: true
          description: The id of the pet to retrieve
          schema:
            type: string
      responses:
        '200':
          description: Expected response to a valid request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Pet"
components:
  schemas:
    Pet:
      type: object
      required:
        - id
        - name
      properties:
        id:
          type: integer
          format: int64
        name:
          type: string
        tag:
          type: string
          deprecated: true
          

Executed command

$  java -Dmodels   -DmodelTests=false -DmodelDocs=false -DdebugModels \
 -jar openapi-generator-cli-4.0.3.jar  generate \
  -g python -i petstore.yaml 

JSON model with -DdebugModels option

 {
      "openApiType" : "string",
      "baseName" : "tag",
      "getter" : "getTag",
      "setter" : "setTag",
      "dataType" : "str",
      "datatypeWithEnum" : "str",
      "name" : "tag",
      "defaultValueWithParam" : " = data.tag;",
      "baseType" : "str",
      "example" : "null",
      "jsonSchema" : "{\n  \"type\" : \"string\",\n  \"deprecated\" : true\n}",
      "exclusiveMinimum" : false,
      "exclusiveMaximum" : false,
      "hasMore" : false,
      "required" : false,
      "secondaryParam" : false,
      "hasMoreNonReadOnly" : false,
      "isPrimitiveType" : true,
      "isModel" : false,
      "isContainer" : false,
      "isString" : true,
      "isNumeric" : false,
      "isInteger" : false,
      "isLong" : false,
      "isNumber" : false,
      "isFloat" : false,
      "isDouble" : false,
      "isByteArray" : false,
      "isBinary" : false,
      "isFile" : false,
      "isBoolean" : false,
      "isDate" : false,
      "isDateTime" : false,
      "isUuid" : false,
      "isUri" : false,
      "isEmail" : false,
      "isFreeFormObject" : false,
      "isListContainer" : false,
      "isMapContainer" : false,
      "isEnum" : false,
      "isReadOnly" : false,
      "isWriteOnly" : false,
      "isNullable" : false,
      "isSelfReference" : false,
      "vendorExtensions" : { },
      "hasValidation" : false,
      "isInherited" : false,
      "nameInCamelCase" : "Tag",
      "nameInSnakeCase" : "TAG",
      "isXmlAttribute" : false,
      "isXmlWrapped" : false,
      "iexclusiveMaximum" : false,
      "datatype" : "str"
    } 

Describe the solution you'd like

Add isDeprecated field to schema object.

Additional context

isDeprecated variable is available in api.mustache file.

@auto-labeler
Copy link

auto-labeler bot commented Jul 14, 2019

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@jimschubert
Copy link
Member

https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#fixed-fields-20

We'll probably want to evaluate the other deprecated fields as well (operations, paths).

@ackintosh
Copy link
Contributor

I'm addressing to this issue for the kotlin-spring generator with my colleague @yutaka0m. 😃

jenseng added a commit to jenseng/openapi-generator that referenced this issue May 14, 2021
Refs OpenAPITools#3358

Ensure `deprecated` operations are annotated/documented as such on the
generated methods. Libraries updated:
  * [feign]
  * [google-api-client]
  * [microprofile]
  * [okhttp-gson]
  * [resttemplate]
  * [retrofit]
  * [retrofit/play*]
  * [webclient]
  * [vertx]

Ensure `deprecated` schemas are annotated/documented as such on the
generated classes/fields. Libraries updated:
  * [feign]
  * [google-api-client]
  * [jersey2]
  * [microprofile]
  * [native]
  * [okhttp-gson]
  * [rest-assured]
  * [resteasy]
  * [resttemplate]
  * [retrofit*]
  * [webclient]
  * [vertx]

Also fix two minor bugs to get the java sample tests working:

* Fix an invalid jackson-datatype-threetenbp version number in vertx/pom.mustache
* Fix a bad return type in webclient/api_test.mustache when uniqueItems=true

Since this commit updates petstore-with-fake-endpoints-models-for-testing.yaml,
several other samples were updated, but it's just new files to reflect the
deprecated schemas, so there should be no consequential differences.

Relevant bits of the spec:

* https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.2.md#user-content-operationdeprecated
* https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.2.md#user-content-schemadeprecated
@cljk
Copy link

cljk commented Jun 9, 2021

Same is the case for all java generators I´ve tested - and I think that are all available.

Marking operations as deprecated is working - but marking model classes or fields as deprecated is not in the generated source code.
I would really like to have this - since this would improve backward compatible API changes.

jenseng added a commit to jenseng/openapi-generator that referenced this issue Jun 29, 2021
Refs OpenAPITools#3358

Ensure `deprecated` operations are annotated/documented as such on the
generated methods. Libraries updated:
  * [feign]
  * [google-api-client]
  * [microprofile]
  * [okhttp-gson]
  * [resttemplate]
  * [retrofit]
  * [retrofit/play*]
  * [webclient]
  * [vertx]

Ensure `deprecated` schemas are annotated/documented as such on the
generated classes/fields. Libraries updated:
  * [feign]
  * [google-api-client]
  * [jersey2]
  * [microprofile]
  * [native]
  * [okhttp-gson]
  * [rest-assured]
  * [resteasy]
  * [resttemplate]
  * [retrofit*]
  * [webclient]
  * [vertx]

Also fix two minor bugs to get the java sample tests working:

* Fix an invalid jackson-datatype-threetenbp version number in vertx/pom.mustache
* Fix a bad return type in webclient/api_test.mustache when uniqueItems=true

Since this commit updates petstore-with-fake-endpoints-models-for-testing.yaml,
several other samples were updated, but it's just new files to reflect the
deprecated schemas, so there should be no consequential differences.

Relevant bits of the spec:

* https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.2.md#user-content-operationdeprecated
* https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.2.md#user-content-schemadeprecated
wing328 pushed a commit that referenced this issue Jul 19, 2021
Refs #3358

Ensure `deprecated` operations are annotated/documented as such on the
generated methods. Libraries updated:
  * [feign]
  * [google-api-client]
  * [microprofile]
  * [okhttp-gson]
  * [resttemplate]
  * [retrofit]
  * [retrofit/play*]
  * [webclient]
  * [vertx]

Ensure `deprecated` schemas are annotated/documented as such on the
generated classes/fields. Libraries updated:
  * [feign]
  * [google-api-client]
  * [jersey2]
  * [microprofile]
  * [native]
  * [okhttp-gson]
  * [rest-assured]
  * [resteasy]
  * [resttemplate]
  * [retrofit*]
  * [webclient]
  * [vertx]

Also fix two minor bugs to get the java sample tests working:

* Fix an invalid jackson-datatype-threetenbp version number in vertx/pom.mustache
* Fix a bad return type in webclient/api_test.mustache when uniqueItems=true

Since this commit updates petstore-with-fake-endpoints-models-for-testing.yaml,
several other samples were updated, but it's just new files to reflect the
deprecated schemas, so there should be no consequential differences.

Relevant bits of the spec:

* https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.2.md#user-content-operationdeprecated
* https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.2.md#user-content-schemadeprecated
@kpaaro
Copy link

kpaaro commented Jan 26, 2022

Same is the case for all java generators I´ve tested - and I think that are all available.

Marking operations as deprecated is working - but marking model classes or fields as deprecated is not in the generated source code. I would really like to have this - since this would improve backward compatible API changes.

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants