davidmoten / openapi-to-plantuml

Converts OpenAPI 3.0 definitions to Plant UML text for visualisation of your API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

openapi uml generation error

orion-belt opened this issue · comments

commented

Hi @davidmoten
I tried to build uml for 5gc openapis. I built openapi-to-plantuml first.
Then I run inside 5gc open api folder -> https://github.com/jdegre/5GC_APIs.git. but I get below error.
Am I doing in correct way ?

5GC_APIs$ java -jar openapi-to-plantuml/target/openapi-to-plantuml-0.1.9-SNAPSHOT-jar-with-dependencies.jar  TS29531_Nnssf_NSSelection.yaml PNG openapi.png11
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.lang.RuntimeException: could not find ref=./TS29571_CommonData.yaml#/components/schemas/NfInstanceId
	at com.github.davidmoten.oas3.internal.Names.refToClassName(Names.java:94)
	at com.github.davidmoten.oas3.internal.Common.getUmlTypeName(Common.java:285)
	at com.github.davidmoten.oas3.internal.Common.getUmlTypeName(Common.java:279)
	at com.github.davidmoten.oas3.internal.Common.getUmlTypeName(Common.java:302)
	at com.github.davidmoten.oas3.internal.Common.getUmlTypeName(Common.java:279)
	at com.github.davidmoten.oas3.internal.Common.lambda$toModelClass$1(Common.java:120)
	at java.base/java.util.LinkedHashMap$LinkedEntrySet.forEach(LinkedHashMap.java:671)
	at com.github.davidmoten.oas3.internal.Common.toModelClass(Common.java:81)
	at com.github.davidmoten.oas3.internal.ComponentsHelper.lambda$toModel$0(ComponentsHelper.java:24)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.reduce(ReferencePipeline.java:553)
	at com.github.davidmoten.oas3.internal.ComponentsHelper.toModel(ComponentsHelper.java:26)
	at com.github.davidmoten.oas3.puml.Converter.openApiToPuml(Converter.java:62)
	at com.github.davidmoten.oas3.puml.Converter.openApiToPuml(Converter.java:55)
	at com.github.davidmoten.oas3.puml.Converter.openApiToPuml(Converter.java:41)
	at com.github.davidmoten.oas3.puml.Converter.openApiToPuml(Converter.java:46)
	at com.github.davidmoten.oas3.puml.ConverterMain.main(ConverterMain.java:42)
5GC_APIs$ 
5GC_APIs$ 
5GC_APIs$ ls | grep TS29571_CommonData.yaml
TS29571_CommonData.yaml

This happens because the library does not support external references (at the moment). The whole definition needs to be in one file. I'll have a think about it to see how much work is involved in supporting that.

I guess an obvious question is how would we want it to look? These are large definitions you are looking at. My first guess is if a.yml references b.yml then we would display all of a.yml and expand visually the referred bits of b.yml (and their references). What do you want to see?

commented

My first guess is if a.yml references b.yml then we would display all of a.yml and expand visually the referred bits of b.yml (and their references).

Hi @davidmoten
Thanks a lot for your response. Yes you are right.
Normally there are common data types in same yaml or different referred yaml.
and I want to visualize their hierarchy.
I did this manual & very dirty UML. Like this perhaps.

I've made a PR so at least you don't get a failure when running the puml generation against a file with external refs. See #61 for your review if you like.

I've release 0.1.9 to Maven Central with this simple external ref handling from #61.

I see the swagger-parser library used internally supports resolution of external refs. Not enabled at the moment clearly but it looks like full support for external refs will be pretty easy.

commented

Hi @davidmoten
Thanks for your information. I have re-built with your changes but I get same error as above.

really? Ok, I'll try it.

Works for me. Creates a dirty big SVG:
image

Just use 0.1.9

Works here too: https://openapi-to-puml.davidmoten.org/prod/site/index.html. Just paste the openapi defintiion in.

commented

Many thanks @davidmoten
It is working for me now.