swagger-api / swagger-converter

OpenAPI/Swagger 2.0 to OpenAPI 3.0 Converter WebService

Home Page:https://converter.swagger.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Objects lose minProperties and maxProperties

hkosova opened this issue · comments

Spec: https://gist.githubusercontent.com/hkosova/699a0398e326376c8f450b2e4107686c/raw/91c7878d3a023a05c4e42634ed2e2fae6ba8c518/minProps-maxProps.yaml

swagger: '2.0'
info:
  version: '1.0'
  title: test

paths:
  /foo:
    post:
      consumes:
        - application/json
      parameters:
        - in: body
          name: body
          required: true
          schema:
            type: object
            minProperties: 1
            maxProperties: 10
      responses:
        200:
          description: OK

definitions:
  Object:
    type: object
    minProperties: 1
    maxProperties: 10

Converted spec:
https://oai.swagger.io/api/convert?url=https://gist.githubusercontent.com/hkosova/699a0398e326376c8f450b2e4107686c/raw/91c7878d3a023a05c4e42634ed2e2fae6ba8c518/minProps-maxProps.yaml

  "paths": {
    "/foo": {
      "post": {
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          },
          "required": true
        },
  ...
  "components": {
    "schemas": {
      "Object": {
        "type": "object"
      }
    }
  }

Request body schema and the Object schema in components are missing minProperties and maxProperties.

commented

This is something we can't fix right now due to limitations in reading the spec. The conversion will work if additionalProperties exists and it's not a root-level definition under definitions. Solving it beyond that would require significant changes to the old code, which would be out of scope for now.

We'll tackle this later on.

Is it fixed for Openspec 3 ?

Is there a workaround that can be used for converting the following file. Converted file loses the minProperties and maxProperties. What is the anticipated timeline for this fix ?

swagger: "2.0"
info:
  version: 1.0-SNAPSHOT
  title: lesson 1
basePath: /v1
paths:
  /accounts:
    post:
      description: Create Account
      operationId: createAccount
      consumes:
      - application/json
      produces:
      - application/json
      parameters:
      - in: body
        name: body
        required: true
        schema:
          "$ref": "#/definitions/Example"
      responses:
        201:
          description: response
          schema:
            type: object


definitions:
  Example:
    description: example body
    type: object
    required:
    - restricted
    - restricted2
    properties:
      restricted:
        description: test
        type: object
        maxProperties: 1
        minProperties: 1
      restricted2:
        description: test
        type: object
        maxProperties: 1
        minProperties: 1