Repository navigation
feat(oas32): render itemSchema of sequential media types - #11099
Open
SahinurDEV wants to merge 2 commits into
Open
SahinurDEV wants to merge 2 commits into
SahinurDEV wants to merge 2 commits into
Conversation
OpenAPI 3.2 Media Type Objects can describe sequential media types (text/event-stream, application/jsonl, multipart/mixed, ...) with itemSchema instead of schema. Responses and request bodies only read schema, so these media types rendered without any example or model. Add a getMediaTypeSchemaField fn that picks itemSchema for OAS 3.2 media types that have no schema, and use it in Response and RequestBody for the model, generated example and spec path. A short note marks the schema as describing each item of the sequence, and itemSchema request bodies are never rendered as form fields. Fixes swagger-api#11065
… feat/oas32-item-schema Signed-off-by: SahinurDEV <68515168+SahinurDEV@users.noreply.github.com> # Conflicts: # src/core/components/response.jsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
OpenAPI 3.2 lets a Media Type Object describe sequential media types (
text/event-stream,application/jsonl,application/json-seq,multipart/mixed, …) withitemSchemainstead ofschema. Swagger UI only ever readschema, so for a response or request body that usesitemSchemathe Example Value / Schema section was simply missing.This adds a
getMediaTypeSchemaField(mediaType)fn:oas3plugin registers a default that always returns"schema", so OAS 3.0/3.1 behaviour is unchanged;oas32plugin overrides it inafterLoadthroughwrapOAS32Fn(same pattern asisFileUploadIntended), returning"itemSchema"when the media type hasitemSchemaand noschema. If both are presentschemastill wins.ResponseandRequestBody(plusgetDefaultRequestBodyValue) use that field for the model, the generated example and the spec path (…/content/<type>/itemSchema), so$refs, model expansion and generated samples work like they do forschema. A small "Schema of each item in the<type>sequence" note is shown above the example/model so it's clear the sample is a single item, not the whole body.itemSchemarequest bodies are never rendered as form fields, since amultipart/mixeditem schema describes each part rather than named fields.I also moved
itemSchemafrom the "not yet implemented" list to the implemented list in theoas32plugin doc comment.Motivation and Context
Fixes #11065
How Has This Been Tested?
test/unit/core/plugins/oas32/item-schema.test.jsx(8 tests):getMediaTypeSchemaFieldcases (onlyitemSchema, both fields, neither, Map and plain object), theafterLoadwrapper returningitemSchemaonly for OAS 3.2 documents,<Response>rendering the model/example/spec path fromitemSchemawith the note (and unchanged output forschema),getDefaultRequestBodyValuebuilding the body fromitemSchema, and<RequestBody>rendering amultipart/mixeditemSchemaas a model instead of a form. 7 of them fail without the source changes.npm run test:unit: 81 suites / 898 tests passed (12 skipped, same as before).npm run lint-errors: clean.Checklist
My PR contains...
src/is unmodified: changes to documentation, CI, metadata, etc.)package.json)My changes...
Documentation
Automated tests