swagger-api / swagger-api/swagger-parser
minProperties and maxProperties null values while reading from swagger 2.0
Open
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 867
- Forks
- 560
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Description
Consider the following swagger 2.0 file (simplified version of petstore)
swagger: '2.0'
info:
description: 'This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.'
version: 1.0.6
title: Swagger Petstore
termsOfService: http://swagger.io/terms/
contact:
email: apiteam@swagger.io
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
host: petstore.swagger.io
basePath: /v2
paths:
/pet/{petId}:
get:
summary: Find pet by ID
description: Returns a single pet
operationId: getPetById
produces:
- application/json
- application/xml
parameters:
- name: petId
in: path
description: ID of pet to return
required: true
type: integer
format: int64
responses:
'200':
description: successful operation
schema:
$ref: '#/definitions/Pet'
'400':
description: Invalid ID supplied
'404':
description: Pet not found
definitions:
Pet:
type: object
required:
- name
- photoUrls
additionalProperties: true
minProperties: 1
maxProperties: 4
properties:
id:
type: integer
format: int64
name:
type: string
example: doggie
photoUrls:
type: array
xml:
wrapped: true
items:
type: string
xml:
name: photoUrl
status:
type: string
description: pet status in the store
enum:
- available
- pending
- sold
If I try to parse as follow
ParseOptions parseOptions = new ParseOptions();
parseOptions.setResolve(true); // implicit
SwaggerParseResult result = new OpenAPIParser().readLocation(f.getAbsolutePath(),null,parseOptions);
OpenAPI swagger = result.getOpenAPI();
I found that the minProperties and maxProperties field of Pet object are null.
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 at OpenAPIParser.readLocation with ParseOptions.setResolve(true), then trace how the Swagger 2.0 Pet schema is mapped into the OpenAPI model. Use the supplied document to verify whether minProperties and maxProperties are retained on the parsed Pet object, and confirm the fields are no longer null.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100