Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Any schema #1022

Closed
sclorng opened this issue Jan 12, 2022 · 3 comments · Fixed by #1347
Closed

Support for Any schema #1022

sclorng opened this issue Jan 12, 2022 · 3 comments · Fixed by #1347
Labels
bug Something isn't working
Milestone

Comments

@sclorng
Copy link

sclorng commented Jan 12, 2022

Currently if we expose an object, the schema is

@Schema(description = "The value of the characteristic", required = true)
public Object getValue() {
    return value;
}

gives

value:
    description: The value of the characteristic
    type: object

Is it possible to not have the type attribute or just {} when no other attribute are present to express an Any schema ?

io.smallrye:smallrye-open-api-core:jar:2.1.17

@MikeEdgar
Copy link
Member

@sclorng - you should be able to set the type to null with an org.eclipse.microprofile.openapi.OASFilter implementation. The model that results from the annotation scan would be made available for modification.

@MikeEdgar MikeEdgar added the question Further information is requested label Jan 18, 2022
@MikeEdgar
Copy link
Member

This should be supported, reference https://swagger.io/docs/specification/data-models/data-types/#any

@MikeEdgar MikeEdgar added bug Something isn't working and removed question Further information is requested labels Feb 19, 2022
@MikeEdgar
Copy link
Member

MikeEdgar commented Feb 19, 2022

@sclorng , you should be able to accomplish this by setting the following property.

mp.openapi.schema.java.lang.Object={ "name": "AnyType" }

Then, given this POJO:

@Schema(name = "TestBean")
class Bean {
    Object any;
}

It will result in something like:

{
  "openapi" : "3.0.3",
  "components" : {
    "schemas" : {
      "TestBean" : {
        "type" : "object",
        "properties" : {
          "any" : {
            "$ref" : "#/components/schemas/AnyType"
          }
        }
      },
      "AnyType" : {}
    }
  }
}

MikeEdgar added a commit to MikeEdgar/smallrye-open-api that referenced this issue Jan 11, 2023
Fixes smallrye#1022

Signed-off-by: Michael Edgar <michael@xlate.io>
MikeEdgar added a commit to MikeEdgar/smallrye-open-api that referenced this issue Jan 11, 2023
Fixes smallrye#1022

Signed-off-by: Michael Edgar <michael@xlate.io>
MikeEdgar added a commit to MikeEdgar/smallrye-open-api that referenced this issue Jan 11, 2023
Fixes smallrye#1022

Signed-off-by: Michael Edgar <michael@xlate.io>
MikeEdgar added a commit to MikeEdgar/smallrye-open-api that referenced this issue Jan 11, 2023
Fixes smallrye#1022

Signed-off-by: Michael Edgar <michael@xlate.io>
@MikeEdgar MikeEdgar added this to the 3.1.3 milestone Jan 11, 2023
MikeEdgar added a commit to MikeEdgar/smallrye-open-api that referenced this issue Jan 13, 2023
Fixes smallrye#1022

Signed-off-by: Michael Edgar <michael@xlate.io>
MikeEdgar added a commit to MikeEdgar/smallrye-open-api that referenced this issue Jan 17, 2023
Fixes smallrye#1022

Signed-off-by: Michael Edgar <michael@xlate.io>
MikeEdgar added a commit to MikeEdgar/smallrye-open-api that referenced this issue Jan 17, 2023
Fixes smallrye#1022

Signed-off-by: Michael Edgar <michael@xlate.io>
MikeEdgar added a commit to MikeEdgar/smallrye-open-api that referenced this issue Jan 29, 2023
Fixes smallrye#1022

Signed-off-by: Michael Edgar <michael@xlate.io>
MikeEdgar added a commit to MikeEdgar/smallrye-open-api that referenced this issue Jan 30, 2023
Fixes smallrye#1022

Signed-off-by: Michael Edgar <michael@xlate.io>
MikeEdgar added a commit that referenced this issue Jan 31, 2023
Fixes #1022

Signed-off-by: Michael Edgar <michael@xlate.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants