swagger-api / swagger-api/swagger-codegen
[Go] [Java] [Client] Adding required to fields
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Swagger-codegen both for go and java can't add required to fields when reusing object.
related to #722
Swagger-codegen version
2.3.1
3.0.4
openapi 2/3
Swagger declaration file content or url
swagger: '2.0'
info:
description: Example
title: Example
version: '1.0.0'
consumes:
- application/json
produces:
- application/json
paths: {}
definitions:
InputWithRequired:
required:
- id
- number
allOf:
- $ref: '#/definitions/Input'
Input:
type: object
properties:
id:
type: number
example: 53
number:
type: string
example: "0000000024"
openapi: 3.0.0
info:
description: Example
title: Example
version: '1.0.0'
paths: {}
components:
schemas:
InputWithRequired:
required:
- id
- number
allOf:
- $ref: '#/components/schemas/Input'
Input:
type: object
properties:
id:
type: number
example: 53
number:
type: string
example: "0000000024"
Documentaion generated with these specs is correct, it specifies that for InputWithRequired id and number fields are required, but for Input they are optional. However generated models both set fields as optional.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the provided Swagger 2.0 and OpenAPI 3.0 declarations using the Go and Java generators. Compare the generated models for InputWithRequired and Input; done means id and number are required only in InputWithRequired, while remaining optional in Input.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100