openapi-preprocessor icon indicating copy to clipboard operation
openapi-preprocessor copied to clipboard

How to split requests, responses, schemas into separate files

Open mrmeyers99 opened this issue 1 year ago • 3 comments

I've been able to merge paths in from multiple files, but we haven't been able to figure out how to split the requests, responses, and schemas into separate schemas. I've created a sample repo that shows what I'm trying to do, and as you can see from the github actions worfklow I get the following error:

/components/requests/helloWorldPayload/content/application~1json/schema: content replaced from /github/workspace/schemas.yaml

Here are the files that I have, but see my github link to download the code if you need it.

spec.yaml (root file)

openapi: 3.0.3
info:
  title: Test spec
  description: |-
    Test spec
  version: 1.0.0

paths:
  $inline: paths.yaml#/paths

paths.yaml

openapi: 3.0.3
info:
  title: Paths
  description: Paths
  version: 1.0.0

paths:
  /helloWorld:
    post:
      description: Say hello
      requestBody:
        $ref: "requests.yaml#/components/requests/helloWorldPayload"
      responses:
        "200":
          $ref: "responses.yaml#/components/responses/helloWorldResponse"

requests.yaml

openapi: 3.0.3
components:
  requests:
    helloWorldPayload:
      content:
        application/json:
          schema:
            $ref: "schemas.yaml#/components/schemas/helloWorldRequestSchema"

responses.yaml

openapi: 3.0.3
components:
  responses:
    helloWorldResponse:
      description: OK
      content:
        application/json:
          schema:
            $ref: 'schemas.yaml#/components/schemas/hellowWorldResponseSchema'

schemas.yaml

openapi: 3.0.1
components:
  schemas:
    helloWorldRequestSchema:
      type: object
      properties:
        name:
          type: string
          description: name

    hellowWorldResponseSchema:
      type: object
      properties:
        message:
          type: string
          description: name

Is what I'm trying to do possible?

mrmeyers99 avatar Feb 09 '24 15:02 mrmeyers99