Giter VIP home page Giter VIP logo

Comments (7)

timonback avatar timonback commented on September 25, 2024

Hi @fcmdeveloper1 ,

Can you share the classes that are involved, again so that we can easily reproduce it?
Or are those the same as in #729 ?

An alternative to uploading the code as zip is to fork the repo, create a new branch, edit the example (https://github.com/springwolf/springwolf-core/blob/master/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/springwolf/examples/kafka/dtos/ExamplePayloadDto.java ; no need to fix tests or anything like that) and commit&push + open a pr to the repo (or your fork)

from springwolf-core.

fcmdeveloper1 avatar fcmdeveloper1 commented on September 25, 2024

Dear @timonback,
yes, exact project, you can reproduce the issue, also, you can see the behavior if you omit the "allOf" and "discriminatorProperty" from the LearningEvent object which is the desired setup to match the swagger default behavior, the eventKey property will not appear in the object.

please, let me know if i can help or support.

My Best Regards

from springwolf-core.

timonback avatar timonback commented on September 25, 2024

Hi @fcmdeveloper1,

I started looking into and created #745 so that we can look at the same thing together.

The code contains two variations - see the commits in the pr

  1. The discriminator field eventKey is added as own field in the Parent class
  2. LearningEvent has the @Schema#allOf property set
  • Variation 1 works out of the box for me, although requires code changes in your event class.
  • Variation 2 produces already the correct spec document, however springwolf-ui cannot handle the anyOf schemas yet. The required changes are included in the PR and you can verify that in the preview deployment.

for swagger, without adding the allOf and discriminatorProperty attributes, everything is working perfectly, which is the expected behavior for both UI and the generated swagger description.

I debugged the output of swagger-parser (which springwolf uses) (excluding the extra field of variation 1, excluding the property in the schema annotation of variation 1). Then 3 fields (eventKey is missing) show up.

What do you mean with swagger? springdoc and its ui?

from springwolf-core.

fcmdeveloper1 avatar fcmdeveloper1 commented on September 25, 2024

Dear @timonback,
i think i was not clear enough, if you omit the allOf and discriminatoProperty from the LearningEvent object, the fields of the parent will not be rendered or will be ignored (you can try yourself) although the object itself clearly extends the ParentObject, that's why i got confused, because, i expect to have all the fields including the eventKey without writing the allOf or the discriminatoProperty attributes, and this is what happens in swagger. with or without these attributes, the UI and properties are rendered perfectly.

also, i didn't get well what do you mean by code changes for variation1.

and for the swagger, yes, i am using springdoc-openapi-ui for the swagger documentation.

My Best Regards

from springwolf-core.

timonback avatar timonback commented on September 25, 2024

Hi @fcmdeveloper1
Lets break it down.
I agree that swagger does not add the field eventKey from the annotations to any object. That might be expected behaviour as the class does not have the field. The field is only used during deserialization and therefore part of the payload, but not within the application.

Therefore, I suggested the alternatives (variations). Both are shown in the reproduce PR in separate commits: d6690f9

Do the alternatives work for you? Or can you investigate what we need to change in springwolf?

from springwolf-core.

fcmdeveloper1 avatar fcmdeveloper1 commented on September 25, 2024

Dear @timonback,
thanks for your suggestions, and this is my comments for both options and i am not sure if it is doable or the changes are huge:

  1. The discriminator field eventKey is added as own field in the Parent class
    i guess this will be difficult and may be misleading to the developers which might at the end lead to having 2 eventKey properties, one from the deserialization and the other from the added class property, which i guess is not best match.
  2. LearningEvent has the @Schema#allOf property set
    i guess this is more suitable especially after you support the allOf for the UI itself, however, it might be more friendly to the developer who is usually using the swagger if you added the same properties from the parent object which is already extended from the object. and i guess we agreed the eventKey is a deserialized property which will appear in all cases.

we can have further discussions if any.

thanks a lot

My Best Regards

from springwolf-core.

timonback avatar timonback commented on September 25, 2024

We discussed, but we do not see another way at this point - besides the 2 offered options.

The library swagger-parser that we use already omits the eventKey field, so Springwolf does not see it either.
You are welcome to suggest a code improvement via a PR.

Apart from that, one improvement regarding the rendering in springwolf-ui has been made that will be part of the next release.

from springwolf-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.