Giter VIP home page Giter VIP logo

Comments (10)

adamw avatar adamw commented on June 12, 2024

There is const in the jsonschema that we use: https://github.com/softwaremill/sttp-apispec/blob/master/apispec-model/src/main/scala/sttp/apispec/Schema.scala#L55

I don't think we should be assing const to sttp.tapir.Schema. That's the high-level representaiton. Possibly, the translation between a tapir schema and an async api schema needs to be adjusted?

from tapir.

adamw avatar adamw commented on June 12, 2024

That's probably the place where the discriminators are generated:

private def tDiscriminatorToADiscriminator(discriminator: TSchemaType.SDiscriminator): Discriminator = {

from tapir.

adamw avatar adamw commented on June 12, 2024

I wonder if the way discriminators are defined for OpenAPI and AsyncAPI diverges? But hopefully we can generate something that works for both cases

from tapir.

kamilkloch avatar kamilkloch commented on June 12, 2024

There is const in the jsonschema that we use: https://github.com/softwaremill/sttp-apispec/blob/master/apispec-model/src/main/scala/sttp/apispec/Schema.scala#L55

True, I think it is not being set anywhere in the schema generation code, though.

I don't think we should be assing const to sttp.tapir.Schema. That's the high-level representaiton. Possibly, the translation between a tapir schema and an async api schema needs to be adjusted?

If I am not mistaken, currently OpenAPI and AsyncApi schemas are rendered in the same way, this leads to an illegal async api spec when using .withDiscriminator: #3754. So yes, it looks like a translation between a tapir schema and an async api schema needs to be adjusted.

from tapir.

kamilkloch avatar kamilkloch commented on June 12, 2024

I wonder if the way discriminators are defined for OpenAPI and AsyncAPI diverges? But hopefully we can generate something that works for both cases

AsyncApi does not support mapping for the discriminator, also discriminator must be a String. It looks like separate rendering paths might be needed - OpenApi conforms to JSON Schema Specification Draft 2020-12, AsyncApi does not.

from tapir.

adamw avatar adamw commented on June 12, 2024

Ah I see. Then I guess we'll need a flag for the TSchemaToASchema class to make this configurable

from tapir.

kamilkloch avatar kamilkloch commented on June 12, 2024

Ah I see. Then I guess we'll need a flag for the TSchemaToASchema class to make this configurable

What would be your suggestion for the flag? Discriminator-specific (we might stumble on other asyncapi/openapi incompatibilities in the future), or perhaps enum OpenApi/AsyncApi/JsonSchema? It seems that ASchema is only used for rendering to one of those specs.

from tapir.

adamw avatar adamw commented on June 12, 2024

Let's start with a simple Boolean flag if we want to generate mappings or consts for discriminators. If there are more such cases, we'll refactor. ASchema is an alias for the sttp-apispec Schema, I think it's used by both?

from tapir.

kamilkloch avatar kamilkloch commented on June 12, 2024

OK, let's roll with a Boolean flag. Yes, ASchema is used by both.

from tapir.

kamilkloch avatar kamilkloch commented on June 12, 2024

Closining for now, see #3765.

from tapir.

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.