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

Custom types converted incorrectly into OpenAPI 3 #67

Closed
reieRMeister opened this issue May 9, 2022 · 2 comments
Closed

Custom types converted incorrectly into OpenAPI 3 #67

reieRMeister opened this issue May 9, 2022 · 2 comments

Comments

@reieRMeister
Copy link

Nominal

Rendering an API Blueprint document to OpenAPI3 with flag --open-api-3 converts a custom type like this:

## MyType (object)
+ id: `4711` (required, string)
+ someProperty (required, nullable, object)
    + someList (required, array)
        + (object)
            + id: `some example`(required, string)

into this:

    MyType:
      type: object
      required:
        - id
        - someProperty
      properties:
        id:
          type: string
          example: 4711
        someProperty:
          type: object
          nullable: true
          required:
            - someList
          properties:
            someList:
              type: array
              items:
                type: object
                required: 
                  - id
                properties:
                  id:
                    type: string
                    example: some example

Actual

Rendering an API Blueprint document to OpenAPI3 with flag --open-api-3 converts a custom type like this:

## MyType (object)
+ id: `4711` (required, string)
+ someProperty (required, nullable, object)
    + someList (required, array)
        + (object)
            + id: `some example`(required, string)

results in:

    MyType:
      type: object
      required:
        - id
        - someProperty
      properties:
        id:
          type: string
        someProperty:
          type: object
          required:
            - someList
          properties:
            someList:
              type: array
              items: {}
          nullable: true

Please note the missing definition in line 16 and the missing example values.

@kminami
Copy link
Owner

kminami commented May 17, 2022

Thank you for reporting!

I have implemented example conversion at v1.15.0.

For the missing definition, we should use fixed-type attribute.
e.g.

## MyType (object)
+ id: `4711` (required, string)
+ someProperty (required, nullable, object)
    + someList (required, array, fixed-type)
        + (object)
            + id: `some example`(required, string)

results in:

    MyType:
      type: object
      required:
        - id
        - someProperty
      properties:
        id:
          type: string
          example: '4711'
        someProperty:
          type: object
          required:
            - someList
          properties:
            someList:
              type: array
              items:
                type: object
                required:
                  - id
                properties:
                  id:
                    type: string
                    example: some example
          nullable: true

@reieRMeister
Copy link
Author

Looks good to me!

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

2 participants