prance
prance copied to clipboard
Keep schema name after resolving
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
+1 on this issue. It would be beneficial to have the name of the reference that got evaluated.
I also upvote this issue