Skip to content

Errors with an apparently valid schema #190

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

Closed
DanBuchan opened this issue Sep 18, 2020 · 1 comment
Closed

Errors with an apparently valid schema #190

DanBuchan opened this issue Sep 18, 2020 · 1 comment

Comments

@DanBuchan
Copy link

Not sure if this is a bug, and I am new to the openapi ecosystem, but I am unable to solve this issue given the documentation provided. I have a very simple API implemented using Django-rest-framework and I have DRF auto-produce the openapi3 schema. I've validated with various tools that the schema is valid. However when I come to use openapi-python-client to generate a lib I get the following warning/errors (which I've abbreviated

Warning(s) encountered while generating. Client was generated, but some pieces may be missing
ERROR parsing PUT /api/gene/{id}/ within default. Endpoint will not be generated.
cannot parse body of endpoint UpdateGene
...
ERROR parsing POST /api/gene/{id}/ within default. Endpoint will not be generated.
cannot parse body of endpoint CreateGene
...
ERROR parsing GET /api/genes within default. Endpoint will not be generated.
cannot parse response of endpoint listGenes

I can not tell from the information provided if this problem is rooted in my use of DRF or openapi-python-client

I include the yaml doc in question below, though it doesn't immediately seem incorrect to me

openapi: 3.0.2
info:
  title: Genedata
  version: 1.0.0
  description: API for interacting with gene records
servers:
  - url: http://127.0.0.1:8080
paths:
  /api/gene/{id}/:
    get:
      operationId: RetrieveGene
      description: ''
      parameters:
      - name: id
        in: path
        required: true
        description: A unique integer value identifying this gene.
        schema:
          type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  gene_id:
                    type: string
                    maxLength: 256
                  entity:
                    type: string
                    maxLength: 256
                  start:
                    type: integer
                    maximum: 2147483647
                    minimum: -2147483648
                  stop:
                    type: integer
                    maximum: 2147483647
                    minimum: -2147483648
                  sense:
                    type: string
                    maxLength: 1
                  start_codon:
                    type: string
                    maxLength: 1
                  ec:
                    properties:
                      id:
                        type: integer
                        readOnly: true
                      ec_name:
                        type: string
                        readOnly: true
                    type: object
                  sequencing:
                    properties:
                      id:
                        type: integer
                        readOnly: true
                      sequencing_factory:
                        type: string
                        readOnly: true
                      factory_location:
                        type: string
                        readOnly: true
                    type: object
                required:
                - gene_id
                - entity
                - sense
                - ec
                - sequencing
          description: ''
    post:
      operationId: CreateGene
      description: ''
      parameters:
      - name: id
        in: path
        required: true
        description: A unique integer value identifying this gene.
        schema:
          type: string
      requestBody:
        content:
          application/json:
            schema: &id001
              properties:
                gene_id:
                  type: string
                  maxLength: 256
                entity:
                  type: string
                  maxLength: 256
                start:
                  type: integer
                  maximum: 2147483647
                  minimum: -2147483648
                stop:
                  type: integer
                  maximum: 2147483647
                  minimum: -2147483648
                sense:
                  type: string
                  maxLength: 1
                start_codon:
                  type: string
                  maxLength: 1
                ec:
                  properties:
                    id:
                      type: integer
                      readOnly: true
                    ec_name:
                      type: string
                      readOnly: true
                  type: object
                sequencing:
                  properties:
                    id:
                      type: integer
                      readOnly: true
                    sequencing_factory:
                      type: string
                      readOnly: true
                    factory_location:
                      type: string
                      readOnly: true
                  type: object
              required:
              - gene_id
              - entity
              - sense
              - ec
              - sequencing
          application/x-www-form-urlencoded:
            schema: *id001
          multipart/form-data:
            schema: *id001
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  gene_id:
                    type: string
                    maxLength: 256
                  entity:
                    type: string
                    maxLength: 256
                  start:
                    type: integer
                    maximum: 2147483647
                    minimum: -2147483648
                  stop:
                    type: integer
                    maximum: 2147483647
                    minimum: -2147483648
                  sense:
                    type: string
                    maxLength: 1
                  start_codon:
                    type: string
                    maxLength: 1
                  ec:
                    properties:
                      id:
                        type: integer
                        readOnly: true
                      ec_name:
                        type: string
                        readOnly: true
                    type: object
                  sequencing:
                    properties:
                      id:
                        type: integer
                        readOnly: true
                      sequencing_factory:
                        type: string
                        readOnly: true
                      factory_location:
                        type: string
                        readOnly: true
                    type: object
                required:
                - gene_id
                - entity
                - sense
                - ec
                - sequencing
          description: ''
    put:
      operationId: UpdateGene
      description: ''
      parameters:
      - name: id
        in: path
        required: true
        description: A unique integer value identifying this gene.
        schema:
          type: string
      requestBody:
        content:
          application/json:
            schema: &id002
              properties:
                gene_id:
                  type: string
                  maxLength: 256
                entity:
                  type: string
                  maxLength: 256
                start:
                  type: integer
                  maximum: 2147483647
                  minimum: -2147483648
                stop:
                  type: integer
                  maximum: 2147483647
                  minimum: -2147483648
                sense:
                  type: string
                  maxLength: 1
                start_codon:
                  type: string
                  maxLength: 1
                ec:
                  properties:
                    id:
                      type: integer
                      readOnly: true
                    ec_name:
                      type: string
                      readOnly: true
                  type: object
                sequencing:
                  properties:
                    id:
                      type: integer
                      readOnly: true
                    sequencing_factory:
                      type: string
                      readOnly: true
                    factory_location:
                      type: string
                      readOnly: true
                  type: object
              required:
              - gene_id
              - entity
              - sense
              - ec
              - sequencing
          application/x-www-form-urlencoded:
            schema: *id002
          multipart/form-data:
            schema: *id002
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  gene_id:
                    type: string
                    maxLength: 256
                  entity:
                    type: string
                    maxLength: 256
                  start:
                    type: integer
                    maximum: 2147483647
                    minimum: -2147483648
                  stop:
                    type: integer
                    maximum: 2147483647
                    minimum: -2147483648
                  sense:
                    type: string
                    maxLength: 1
                  start_codon:
                    type: string
                    maxLength: 1
                  ec:
                    properties:
                      id:
                        type: integer
                        readOnly: true
                      ec_name:
                        type: string
                        readOnly: true
                    type: object
                  sequencing:
                    properties:
                      id:
                        type: integer
                        readOnly: true
                      sequencing_factory:
                        type: string
                        readOnly: true
                      factory_location:
                        type: string
                        readOnly: true
                    type: object
                required:
                - gene_id
                - entity
                - sense
                - ec
                - sequencing
          description: ''
    delete:
      operationId: DestroyGene
      description: ''
      parameters:
      - name: id
        in: path
        required: true
        description: A unique integer value identifying this gene.
        schema:
          type: string
      responses:
        '204':
          description: ''
  /api/genes:
    get:
      operationId: listGenes
      description: 'Get a list of genes'
      parameters: []
      responses:
        '200':
          content:
            application/json:
              schema:
                type: array
                items:
                  properties:
                    id:
                      type: integer
                      readOnly: true
                    gene_id:
                      type: string
                      maxLength: 256
                  required:
                  - gene_id
          description: 'Sucesfully returns gene list'
@dbanty
Copy link
Collaborator

dbanty commented Sep 18, 2020

@DanBuchan I don't think there's anything wrong with your schema. openapi-python-client doesn't support inline objects yet (#125, #140, and #162 all complain about this- it's high on the todo list). For now any object-like schemas have to be declared using components and then accessed using a ref

"schema": {
      "$ref": "#/components/schemas/GeneralError"
 }

I'm going to close this issue since I have some many already asking about the same thing 😅. I expect 0.6.0 to be released early next week, then I'll start work on the features for 0.7.0 which will include this.

@dbanty dbanty closed this as completed Sep 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants