question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Properties can not be defined in @Schema

See original GitHub issue

@agiertli asked on Gitter (Jun 24 15:28) following question:


Hi folks,

I am trying to annotate a parameter which holds an uploaded file in my POST request:

The final OpenAPI spec should look like this: https://swagger.io/docs/specification/describing-request-body/file-upload/

      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                fileName:
                  type: string
                  format: binary

I can’t seem to find a suitable way how to define ‘properties’., when using MicroProfile annotations for OpenAPI. So far, I have this:

public Response processInvoice(
        @RequestBody(content = @Content(mediaType = "multipart/form-data", schema = @Schema(type = SchemaType.OBJECT))) MultipartFormDataInput input)

Which generates:

      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object

So it seems I am on the right track, but not sure how to proceed further…any ideas?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:17 (17 by maintainers)

github_iconTop GitHub Comments

2reactions
arthurdmcommented, Aug 13, 2019

I agree with the above proposal

1reaction
EricWittmanncommented, Jul 17, 2019

I think that a fairly simple solution to this (and perhaps one that is not controversial) would be to introduce properties to the @Schema annotation. So for example, an application of the @Schema annotation might look like this:

@Schema(properties={
    @Schema(name="creditCard", required=true),
    @Schema(name="departtureFlight", description="The departure flight information."),
    @Schema(name="returningFlight")
})

This would allow the developer to describe any properties at all.

Read more comments on GitHub >

github_iconTop Results From Across the Web

json - Property has not been defined and the schema does ...
The additionalProperties keyword only considers the properties and patternProperties defined in the immediate subschema where it appears.
Read more >
"The property ... is not defined and the definition does ...
The validation schema expects that only properties that are defined in the JSON schema are to be used within a constraint schema. As...
Read more >
Schema of a JSON object has no properties defined
The schema for a JSON payload does not have any properties defined. ... However, the actual content of that JSON object is not...
Read more >
object — Understanding JSON Schema 2020-12 ...
The properties (key-value pairs) on an object are defined using the properties ... Any properties that do not match either regular expression are...
Read more >
Schema validation reference for object types
The schema defines the JSON schema version to be used to validate the input schema. Since custom objects use their own custom schema,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found