openapi-comment-parser icon indicating copy to clipboard operation
openapi-comment-parser copied to clipboard

Add support for "inline" objects in response and request body

Open mbokinala opened this issue 5 years ago • 6 comments

I want to use the responseContent comment to specify an object response

mbokinala avatar Nov 21 '20 07:11 mbokinala

What do you mean by inline?

bourdakos1 avatar Nov 21 '20 12:11 bourdakos1

I think it's for jsodc object (schema) declaration like beelow

/**
 * SCHEMAS JWS
 * {
 *   "header": ... ,
 *   "payload": ... ,
 *   "signature": ....
 * }
/*

/**
 * POST /auth/token
 * @summary Return a valid jwt
 * @bodyContent {JWS} A valid Jws with x5c cert chain
 * @bodyRequired
 * @description Get a valid jwt
 * @response 200 - OK
 * @responseContent {jwt} 200.application/json
 */

or something like that or directly in yml.

I need this too ;) It's juste for convenience to declare schemas where they are used.

aurelhann avatar Nov 30 '20 07:11 aurelhann

Ah gotcha, I went with yaml because I don’t like dealing with whitespace in jsdoc. But it shouldn’t be too hard to add if people find it useful :)

I’d also be happy to merge any pull requests if someone wanted to take a stab at building the feature?

bourdakos1 avatar Nov 30 '20 07:11 bourdakos1

I could do that cause I need it !

:)

aurelhann avatar Nov 30 '20 08:11 aurelhann

two proposals. First of all a simple part of component declaration in yml like we discuss before

/**

        components:
          schemas:
            JWS:
              properties:
                header:
                  type: string
                payload:
                  type: string
                signature:
                  type: string
    **/

or use the https://github.com/john-doherty/jsdoc-to-json-schema proposal

/**
 * @schema.name JWS
 */
const JWS = {

    /**
     * @schema.title Header
     * @schema.type string
     * @schema.required true
     */
    header: '',

 /**
     * @schema.title Payload
     * @schema.type string
     * @schema.required true
     */
    payload: '',

 /**
     * @schema.title Signature
     * @schema.type string
     * @schema.required true
     */
    signature: '',
}

John use the jsdoc schema tag it's quite concise format in jsdoc and refer directly to an object creation. The integration is more straigth forward with the second because of the JSON schema integration in openAPI format.

I could try today an implementation of the second. Tel me @bourdakos1 if you think it's a good idea in order to merge it of course ! ;)

aurelhann avatar Dec 13 '20 09:12 aurelhann

I really like the second example! Would be more than happy to merge that feature 😁

bourdakos1 avatar Dec 13 '20 13:12 bourdakos1