Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Objects lose minProperties and maxProperties #24

Open
hkosova opened this issue Sep 13, 2017 · 3 comments
Open

Objects lose minProperties and maxProperties #24

hkosova opened this issue Sep 13, 2017 · 3 comments

Comments

@hkosova
Copy link

hkosova commented Sep 13, 2017

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.

@webron
Copy link
Contributor

webron commented Sep 14, 2017

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.

@RamiaSaidawi
Copy link

Is it fixed for Openspec 3 ?

@jj185118
Copy link

jj185118 commented Jul 15, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants