nlohmann / swagger_to_uml Goto Github PK
View Code? Open in Web Editor NEWConvert OpenAPI specifications (a.k.a. Swagger) to PlantUML diagrams
License: MIT License
Convert OpenAPI specifications (a.k.a. Swagger) to PlantUML diagrams
License: MIT License
Extended Pet example to include Cat and Dog using allOf example from here: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md
Get the following error:
`python swagger_to_uml.py swagger.json > swagger.puml
required key "type" not found in dictionary {"description": "A representation of a cat", "allOf": [{"$ref": "#/definitions/Pet"}, {"type": "object", "properties": {"huntingSkill": {"type": "string", "description": "The measured skill for hunting", "default": "lazy", "enum": ["clueless", "lazy", "adventurous", "aggressive"]}}, "required": ["huntingSkill"]}]}
Traceback (most recent call last):
File "swagger_to_uml.py", line 380, in
sw = Swagger.from_file(input_file_name)
File "swagger_to_uml.py", line 367, in from_file
return Swagger.from_dict(loader(fd))
File "swagger_to_uml.py", line 357, in from_dict
definitions = [Definition.from_dict(name, definition) for name, definition in d.get('definitions',{}).items()]
File "swagger_to_uml.py", line 357, in
definitions = [Definition.from_dict(name, definition) for name, definition in d.get('definitions',{}).items()]
File "swagger_to_uml.py", line 204, in from_dict
type=d['type'],
KeyError: 'type'
Modified swagger attached
Hi
I tried to run python part of processing calling
python swagger_to_uml.py petstore_example/swagger.json >petstore_example/swagger.puml
and i got message like this
"File "swagger_to_uml.py", line 376
print(sw.uml, end='', flush=True)"
Do you have idea what I'm doing wrong ? :)
Thanks for info :-)
Best regards
I get this error:
Traceback` (most recent call last):
File "swagger_to_uml.py", line 380, in <module>
sw = Swagger.from_file(input_file_name)
File "swagger_to_uml.py", line 367, in from_file
return Swagger.from_dict(loader(fd))
File "swagger_to_uml.py", line 357, in from_dict
definitions = [Definition.from_dict(name, definition) for name, definition in d.get('definitions',{}).items()]
File "swagger_to_uml.py", line 357, in <listcomp>
definitions = [Definition.from_dict(name, definition) for name, definition in d.get('definitions',{}).items()]
File "swagger_to_uml.py", line 197, in from_dict
required=property_name in d.get('required', [])
File "swagger_to_uml.py", line 103, in from_dict
items = resolve_ref(type_dict['items']['$ref'])
KeyError: '$ref'
Fixed:
c103
< items = resolve_ref(type_dict['items']['$ref']) if '$ref' in type_dict['items'] else None
c364
< if filename.endswith('.yml') or filename.endswith('.yaml'):
Sorry cant do pull req due to ... policy
Hello, I really appreciate this tool. Since the python script was converted to shell script with setup it no longer works for me or I do not understand how to use it. I reverted to older version and was able to use it with the script. When you have time can you please update the README to explain how to use this with the new shell script. Thank you!
Path is replaced with $ref to an openapi yaml stored html.
Example:
paths:
/:
$ref: 'https://artifactory.mycompany.com/artifactory/maven/com/apis/common/0.1.0-20210924151918/common-0.1.0-20210924151918.yaml#/paths/New'
/instances:
$ref: 'https://artifactory.mycompany.com/artifactory/maven/com/apis/common/0.1.0-20210924151918/common-0.1.0-20210924151918.yaml#/paths/GetInstanceIds'
swagger_to_uml throws the following error
Traceback (most recent call last):
File "C:/Users/212708371/Documents/Gitlab/build-util/swagger_to_uml.py", line 367, in from_file
return Swagger.from_dict(loader(fd))
File "C:/Users/212708371/Documents/Gitlab/build-util/swagger_to_uml.py", line 357, in from_dict
paths = [Path.from_dict(d, path_name, path) for path_name, path in d['paths'].items()]
File "C:/Users/212708371/Documents/Gitlab/build-util/swagger_to_uml.py", line 357, in
paths = [Path.from_dict(d, path_name, path) for path_name, path in d['paths'].items()]
File "C:/Users/212708371/Documents/Gitlab/build-util/swagger_to_uml.py", line 336, in from_dict
operations=[Operation.from_dict(whole, path_name, t, op, parameters) for t, op in d.items() if t not in ['parameters', 'summary', 'description']]
File "C:/Users/212708371/Documents/Gitlab/build-util/swagger_to_uml.py", line 336, in
operations=[Operation.from_dict(whole, path_name, t, op, parameters) for t, op in d.items() if t not in ['parameters', 'summary', 'description']]
File "C:/Users/212708371/Documents/Gitlab/build-util/swagger_to_uml.py", line 286, in from_dict
summary=d.get('summary'),
I am assuming that it would also throw errors for my Parameters and Schemas which also reference html but it fails before getting to those
If there are plus chars in the name of an entity, they are not correctly masked.
workaround:
sed -i 's#\([^ ]*[+][^ ]*\)#"\1"#g' swagger.puml
before image creation
I successfully generated a diagram for the petstore API, but failed on this file:
https://consumerdatastandardsaustralia.github.io/standards/includes/swagger/cds_full.json
The file passes a validation test, but I can't rule out a problem with the file (or my local setup).
Hello,
I need to define property UnitGameSystem.profiles with an array of multiple type of object ProfileXXX whish are inherited of object Profile
...
UnitGameSystem:
properties:
id:
type: string
name:
type: string
profiles:
items:
allOf:
- $ref: '#/definitions/ProfileAOS4'
- $ref: '#/definitions/ProfileWFB9'
- $ref: '#/definitions/ProfileWFB12'
- $ref: '#/definitions/ProfileWHQ'
- $ref: '#/definitions/ProfileT9A12'
type: array
...
I have an error for this definition
d:\PROJECTS\swagger_to_uml>python swagger_to_uml.py fantasy-battle-db.swagger.json > fantasy-battle-db.puml
Traceback (most recent call last):
File "d:\PROJECTS\swagger_to_uml\swagger_to_uml.py", line 380, in <module>
sw = Swagger.from_file(input_file_name)
File "d:\PROJECTS\swagger_to_uml\swagger_to_uml.py", line 367, in from_file
return Swagger.from_dict(loader(fd))
File "d:\PROJECTS\swagger_to_uml\swagger_to_uml.py", line 356, in from_dict
definitions = [Definition.from_dict(name, definition) for name, definition in d.get('definitions',{}).items()]
File "d:\PROJECTS\swagger_to_uml\swagger_to_uml.py", line 356, in <listcomp>
definitions = [Definition.from_dict(name, definition) for name, definition in d.get('definitions',{}).items()]
File "d:\PROJECTS\swagger_to_uml\swagger_to_uml.py", line 193, in from_dict
properties.append(Property.from_dict(
File "d:\PROJECTS\swagger_to_uml\swagger_to_uml.py", line 102, in from_dict
items = resolve_ref(type_dict['items']['$ref'])
KeyError: '$ref'
full json is : fantasy-battle-db.swagger.json.txt
Thank's you
This tool doesnt appear to be on PyPI yet.
Hi I was used to use this good tool some year ago to fully document my APIs
What about JSON Schema support ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.