{"action":"opened","issue":{"url":"https://api.github.com/repos/OpenAPITools/openapi-generator/issues/417","repository_url":"https://api.github.com/repos/OpenAPITools/openapi-generator","labels_url":"https://api.github.com/repos/OpenAPITools/openapi-generator/issues/417/labels{/name}","comments_url":"https://api.github.com/repos/OpenAPITools/openapi-generator/issues/417/comments","events_url":"https://api.github.com/repos/OpenAPITools/openapi-generator/issues/417/events","html_url":"https://github.com/OpenAPITools/openapi-generator/issues/417","id":336881830,"node_id":"MDU6SXNzdWUzMzY4ODE4MzA=","number":417,"title":"[JAVA] discriminator.mapping is not supported (in generated model)","user":{"login":"0v1se","id":32102012,"node_id":"MDQ6VXNlcjMyMTAyMDEy","avatar_url":"https://avatars3.githubusercontent.com/u/32102012?v=4","gravatar_id":"","url":"https://api.github.com/users/0v1se","html_url":"https://github.com/0v1se","followers_url":"https://api.github.com/users/0v1se/followers","following_url":"https://api.github.com/users/0v1se/following{/other_user}","gists_url":"https://api.github.com/users/0v1se/gists{/gist_id}","starred_url":"https://api.github.com/users/0v1se/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/0v1se/subscriptions","organizations_url":"https://api.github.com/users/0v1se/orgs","repos_url":"https://api.github.com/users/0v1se/repos","events_url":"https://api.github.com/users/0v1se/events{/privacy}","received_events_url":"https://api.github.com/users/0v1se/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-29T06:43:38Z","updated_at":"2018-06-29T06:43:38Z","closed_at":null,"author_association":"NONE","body":"##### Description\r\n\r\nspec: https://swagger.io/docs/specification/data-models/inheritance-and-polymorphism/\r\nmapping can be specified in discriminator:\r\n```yaml\r\ndiscriminator:\r\n  propertyName: petType\r\n  mapping:\r\n    dogggg: '#/components/schemas/Dog'\r\n    catttt: '#/components/schemas/Cat'\r\n```\r\nCurrently it's not taken in account when generating model (it's not for Java, may be for every other language too)\r\n\r\n##### openapi-generator version\r\n\r\n3.1.0-SNAPSHOT\r\n\r\n##### OpenAPI declaration file content or url\r\n<details>\r\n\r\n```yaml\r\nopenapi: \"3.0.0\"\r\ninfo:\r\n  version: 1.0.0\r\n  title: Swagger Petstore\r\n  license:\r\n    name: MIT\r\nservers:\r\n  - url: http://petstore.swagger.io/v1\r\npaths:\r\n  /pets:\r\n    get:\r\n      summary: List all pets\r\n      operationId: listPets\r\n      tags:\r\n        - pets\r\n      parameters:\r\n        - name: limit\r\n          in: query\r\n          description: How many items to return at one time (max 100)\r\n          required: false\r\n          schema:\r\n            type: integer\r\n            format: int32\r\n      responses:\r\n        '200':\r\n          description: A paged array of pets\r\n          headers:\r\n            x-next:\r\n              description: A link to the next page of responses\r\n              schema:\r\n                type: string\r\n          content:\r\n            application/json:\r\n              schema:\r\n                $ref: \"#/components/schemas/Pets\"\r\n        default:\r\n          description: unexpected error\r\n          content:\r\n            application/json:\r\n              schema:\r\n                $ref: \"#/components/schemas/Error\"\r\n    post:\r\n      summary: Create a pet\r\n      operationId: createPets\r\n      tags:\r\n        - pets\r\n      responses:\r\n        '201':\r\n          description: Null response\r\n        default:\r\n          description: unexpected error\r\n          content:\r\n            application/json:\r\n              schema:\r\n                $ref: \"#/components/schemas/Error\"\r\n  /pets/{petId}:\r\n    get:\r\n      summary: Info for a specific pet\r\n      operationId: showPetById\r\n      tags:\r\n        - pets\r\n      parameters:\r\n        - name: petId\r\n          in: path\r\n          required: true\r\n          description: The id of the pet to retrieve\r\n          schema:\r\n            type: string\r\n      responses:\r\n        '200':\r\n          description: Expected response to a valid request\r\n          content:\r\n            application/json:\r\n              schema:\r\n                $ref: \"#/components/schemas/Pets\"\r\n        default:\r\n          description: unexpected error\r\n          content:\r\n            application/json:\r\n              schema:\r\n                $ref: \"#/components/schemas/Error\"\r\ncomponents:\r\n  schemas:\r\n    Pet:\r\n      type: object\r\n      discriminator:\r\n        propertyName: petType\r\n        mapping:\r\n          dogggg: '#/components/schemas/Dog'\r\n          catttt: '#/components/schemas/Cat'\r\n      properties:\r\n        name:\r\n          type: string\r\n        petType:\r\n          type: string\r\n      required:\r\n      - name\r\n      - petType\r\n    Cat:\r\n      description: A representation of a cat\r\n      allOf:\r\n      - $ref: '#/components/schemas/Pet'\r\n      - type: object\r\n        properties:\r\n          huntingSkill:\r\n            type: string\r\n            description: The measured skill for hunting\r\n            enum:\r\n            - clueless\r\n            - lazy\r\n            - adventurous\r\n            - aggressive\r\n        required:\r\n        - huntingSkill\r\n    Dog:\r\n      description: A representation of a dog\r\n      allOf:\r\n      - $ref: '#/components/schemas/Pet'\r\n      - type: object\r\n        properties:\r\n          packSize:\r\n            type: integer\r\n            format: int32\r\n            description: the size of the pack the dog is from\r\n            default: 0\r\n            minimum: 0\r\n        required:\r\n        - packSize\r\n    Pets:\r\n      type: array\r\n      items:\r\n        $ref: \"#/components/schemas/Pet\"\r\n    Error:\r\n      required:\r\n        - code\r\n        - message\r\n      properties:\r\n        code:\r\n          type: integer\r\n          format: int32\r\n        message:\r\n          type: string\r\n```\r\n\r\n</details>\r\n\r\n##### Command line used for generation\r\n\r\njava -jar ... generate -i api.yaml -g java --library resttemplate\r\n\r\n##### Steps to reproduce\r\n\r\nGenerate model\r\nHere is what's generated in Pet.java:\r\n```java\r\n@JsonSubTypes({\r\n  @JsonSubTypes.Type(value = Cat.class, name = \"Cat\"),\r\n  @JsonSubTypes.Type(value = Dog.class, name = \"Dog\"),\r\n})\r\n```\r\n\r\n##### Related issues/PRs\r\n\r\nRelated to https://github.com/OpenAPITools/openapi-generator/issues/197\r\n\r\n##### Suggest a fix/enhancement\r\n\r\nShould generate model like this:\r\n```java\r\n@JsonSubTypes({\r\n  @JsonSubTypes.Type(value = Cat.class, name = \"catttt\"),\r\n  @JsonSubTypes.Type(value = Dog.class, name = \"dogggg\"),\r\n})\r\n```\r\n"}}
{"actor":{"display_login":"0v1se"}}