OpenAPITools / OpenAPITools/openapi-generator

[REQ] Add `isDeprecated` field to schema object.

Open
#3,358 5 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the generate command using the supplied petstore.yaml and -DdebugModels to inspect the schema model for the deprecated tag field. Compare the existing isDeprecated value in api.mustache with the missing value needed by model.mustache. Done means the debug model exposes isDeprecated and model.mustache can use it for deprecated fields.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.