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.

Generate schemas from paths.

See original GitHub issue

Want to be able to create models from paths schemas. Is there any way to nest and generate also from that level? Example for that snippet:

paths:
  /users/{id}:
    get:
      tags:
        - Users
      summary: Gets a user by ID.
      description: >
        A detailed description of the operation.
        Use markdown for rich text representation,
        such as **bold**, *italic*, and [links](https://swagger.io).
      operationId: getUserById
      parameters:
        - name: id
          in: path
          description: User ID
          required: true
          schema:
            type: integer
            format: int64

model name getUserById with matching params.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
koxudaxicommented, May 20, 2021

@DavidMeu Thank you for creating this issue. I feel that this idea is good. I will add the feature as a CLI option.

1reaction
koxudaxicommented, Aug 9, 2021

@DavidMeu I’m sorry for my late reply. I put the example.

$ datamodel-codegen --input openapi.yaml --openapi-scopes  schemas paths --input-file-type openapi

Output

# generated by datamodel-codegen:
#   filename:  openapi.yaml
#   timestamp: 2021-08-09T18:11:18+00:00

from __future__ import annotations

from typing import Optional

from pydantic import BaseModel, Field


class ObjectsPostRequest(BaseModel):
    name: Optional[str] = Field(
        None, description='The name of the obj', example='example'
    )
    source: Optional[str] = Field(None, description='description.', example='example')


Read more comments on GitHub >

github_iconTop Results From Across the Web

Schema Paths Tool | Schema Markup Entity Relationship ...
The Schema App Paths Tool assists in determining how to nest Schema data types within Schema Markup in relation to other Schema data...
Read more >
Documentation: 15: 5.9. Schemas - PostgreSQL
Keep the default search path, and grant privileges to create in the public schema. All users access the public schema implicitly. This simulates...
Read more >
vega/ts-json-schema-generator - GitHub
Generate JSON schema from your Typescript sources. Contribute to vega/ts-json-schema-generator development by creating an account on GitHub.
Read more >
Schemas - Django REST framework
pyyaml is used to generate schema into YAML-based OpenAPI format. uritemplate is used internally to get parameters in path.
Read more >
Paths and Operations - Swagger
API paths and operations are defined in the global paths section of the API ... Here is a more detailed example with parameters...
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