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

Keep schema name after resolving #151

Open
catcombo opened this issue May 6, 2023 · 2 comments
Open

Keep schema name after resolving #151

catcombo opened this issue May 6, 2023 · 2 comments

Comments

@catcombo
Copy link

catcombo commented May 6, 2023

Expected Behaviour

Hi and thank you for the great library! I like how it's written and works very stable. Good work!

I try to use ResolvingParser for my custom OpenAPI code generator. The problem is when it resolves references it doesn't keep the referenced schema name in the output spec. Is it possible to provide original schema name to the output or access it somehow with the minimal effort? Or maybe put the name to some custom OpenAPI extension field similar to x-enum-varnames or use existing field (e.g. title)?

{
  "openapi": "3.0.2",
  "info": {
    "title": "Demo",
    "version": "1.0"
  },
  "paths": {
    "/demo": {
      "get": {
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "x-schema-name": "SampleModel",
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  }
}

Minimal Example Spec

api.yml

openapi: '3.0.2'

info:
  title: Demo
  version: '1.0'

paths:
  /demo:
    get:
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: 'demo.yml#/components/schemas/SampleModel'

demo.yml

components:
  schemas:
    SampleModel:
      type: string

Actual Behaviour

{
  "openapi": "3.0.2",
  "info": {
    "title": "Demo",
    "version": "1.0"
  },
  "paths": {
    "/demo": {
      "get": {
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  }
}

Steps to Reproduce

Run prance compile api.yml output.json

Environment

  • OS: Fedora 37
  • Python version: 3.11.2
  • Swagger/OpenAPI version used: 3.0.2
  • Backend: openapi-spec-validator
@moisesbenzan
Copy link

+1 on this issue. It would be beneficial to have the name of the reference that got evaluated.

@andruhamax
Copy link

I also upvote this issue

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

3 participants